package com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.EmployeeDao;
import com.dao.ProjectDao;
import com.pojo.Employee;
import com.pojo.Project;
@Service("ProjectService")
public class ProjectServiceImpl implements ProjectService {

	@Autowired
	private ProjectDao projectDao;
	@Autowired
	private EmployeeDao employeeDao;
	@Override
	public boolean addProject(Project project) {
		// TODO Auto-generated method stub
		boolean result;
		if(projectDao.addProject(project)>0)
			result= true;
		else
			result= false;
		return result;
	}

	@Override
	public boolean deleteProjectForId(Integer project_id) {
		// TODO Auto-generated method stub
		boolean result;
		if(projectDao.deleteProjectForId(project_id)>0)
			result= true;
		else
			result=false;
		return result;
	}

	@Override
	public Project GetProject(Integer project_id) {
		// TODO Auto-generated method stub
		return projectDao.selectProjectForId(project_id);
	}

	@Override
	public List<Project> GetAllProject() {
		// TODO Auto-generated method stub
		return projectDao.selectAllProject();
	}

	@Override
	public boolean updateProject(Project project) {
		// TODO Auto-generated method stub
		boolean result;
		if(projectDao.deleteProjectForId(project.getProject_Id())>0&&projectDao.addProject(project)>0)
			result=true;
		else
			result=false;
		return result;
	}

	@Override
	public Employee GetEmployee(Integer employee_id) {
		// TODO Auto-generated method stub
		return employeeDao.selectEmployeeForId(employee_id);
	}
}
